FileSyncToLastLine Subroutine

public subroutine FileSyncToLastLine(fileUnit, blanks)

synchronize to the last line of formatted file

Arguments

Type IntentOptional Attributes Name
integer(kind=short), intent(in) :: fileUnit

unit of file to sync

integer(kind=short), intent(in) :: blanks

number of blank lines to add


Variables

Type Visibility Attributes Name Initial
integer(kind=short), public :: i
integer(kind=short), public :: ios

Source Code

SUBROUTINE FileSyncToLastLine &
!
(fileUnit, blanks)

IMPLICIT NONE

!Arguments with intent(in):
INTEGER (KIND = short), INTENT(IN) :: fileUnit !!unit of file to sync
INTEGER (KIND = short), INTENT(IN) :: blanks !!number of blank lines to add

! Local declarations:  
INTEGER (KIND = short) :: ios
INTEGER (KIND = short) :: i
!------------end of declaration------------------------------------------------

!rewind file before starting
REWIND (fileUnit)

!read till the end of file
DO 
  READ ( fileUnit, *, IOSTAT = ios ) 
  IF (ios /= 0) EXIT
END DO

!add blanck lines
DO i = 1, blanks
  WRITE ( fileUnit, *)
END DO

RETURN
END SUBROUTINE FileSyncToLastLine